<template>
    <div class="app-container">
        <!--        使用ref引用获取dom-->
        <h1 ref="myh1">App 根组件 -- {{ countFormSon }}</h1>
        <button @click="showRed">h1渲染红色</button>
        <hr/>

        <div class="box">
            <!-- 渲染 Left 组件和 Right 组件 -->
            <Left :msg="message" :user="userInfo"></Left>
            <Right @numchange="getNewCount"></Right>
        </div>
    </div>
</template>

<script>
import Left from "@/components/Left.vue";
import Right from "@/components/Right.vue";

export default {
    components: {Left, Right},
    data() {
        return {
            message: 'hello world',
            userInfo: {name: 'zs', age: 18},
            countFormSon: 0
        }
    },
    comments: {
        Left
    },
    methods: {
        getNewCount(val) {
            this.countFormSon = val
        },
        showRed() {
            this.$refs.myh1.style.color = 'red'
        }
    }
}
</script>

<style lang="less">
.app-container {
  padding: 1px 20px 20px;
  background-color: #efefef;
}

.box {
  display: flex;
}
</style>
